//
//  ECTextFieldView.m
//  ECERP.CRM
//
//  Created by Mac on 2018/10/18.
//  Copyright © 2018年 Mac. All rights reserved.
//

#import "ECTextFieldView.h"

@interface ECTextFieldView ()

@property (nonatomic,strong) CAShapeLayer * bottomLineLayer;

@end

@implementation ECTextFieldView

- (instancetype)initWithFrame:(CGRect)frame iconString:(NSString *)str  placeholder:(NSString *)placeholderStr{
    if (self = [super initWithFrame:frame]) {
        self.markImageVIew.image=[UIImage imageNamed:str];
        self.tf.placeholder=placeholderStr;
        [self addSubview:self.markImageVIew];
        [self addSubview:self.tf];
        [self.layer addSublayer:self.bottomLineLayer];
        
    }
    return self;
}


- (UIImageView *)markImageVIew
{
    if (!_markImageVIew) {
        _markImageVIew=[[UIImageView alloc]init];
        _markImageVIew.frame=CGRectMake(0, 12, 24, 24);
    }
    return _markImageVIew;
}


- (UITextField *)tf
{
    if (!_tf) {
        _tf=[[UITextField alloc]init];
        _tf.frame=CGRectMake(self.markImageVIew.right, 0,self.width-24, self.height-1);
        _tf.clearButtonMode=UITextFieldViewModeWhileEditing;
        _tf.textAlignment=NSTextAlignmentCenter;
    }
    return _tf;
}
- (CAShapeLayer *)bottomLineLayer {
    if (!_bottomLineLayer) {
        _bottomLineLayer = [CAShapeLayer layer];
        _bottomLineLayer.borderWidth = 0.5;
        _bottomLineLayer.borderColor = ECCOLOR_TEXTBOTTOMLINE.CGColor;
        _bottomLineLayer.frame=CGRectMake(0, self.height-0.5, self.width, 0.5);
    }
    return _bottomLineLayer;
}

@end
